package solved;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
 ID:	liluyan1
 LANG:	JAVA
 TASK:	ride
 */
public class ride {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("ride.in"));
		String comet = f.readLine().trim();
		String group = f.readLine().trim();
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"ride.out")));
		out.println(new ride().run(comet, group) ? "GO" : "STAY");
		out.close();
		System.exit(0);
	}

	public boolean run(String comet, String group) throws IOException {
		return score(comet) == score(group);
	}

	private int score(String name) {
		int s = 1;
		for (char c : name.toCharArray()) {
			s = s * (c - 'A' + 1) % 47;
		}
		return s;
	}
}
